import 'package:flutter/material.dart';
import 'package:moment_dart/moment_dart.dart';
import 'package:spendbook/common/icons.dart';

final List<String> bankNames = <String>['中国工商银行', '中国农业银行', '中国建设银行', '中国银行', '交通银行', '浦发银行', '招商银行', '民生银行', '兴业银行', '中兴银行', '支付宝', '微信', '其他'];

final List<String> monthMap = <String>['一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月'];

final List<Color> colorList = <Color>[Color(0xff0293ee), Color(0xff845bef), Color(0xff90ed7d), Color(0xfff8b250), Color(0xff61a0a8), Color(0xff61a0a8), Color(0xff91c7ae), Color(0xff13d38e)];

final Map<String, dynamic> themeList = {
  'light': {'text': Text('紫色幻想'), 'getTheme': (BuildContext context) => ThemeData(brightness: Brightness.light)},
  'dark': {'text': Text('黑色幽默'), 'getTheme': (BuildContext context) => ThemeData(brightness: Brightness.dark)},
  'pink': {'text': Text('粉色女郎'), 'getTheme': (BuildContext context) => ThemeData(useMaterial3: false, primarySwatch: Colors.pink, primaryColorLight: Colors.pinkAccent, primaryColorDark: Colors.pink)},
  'blue': {'text': Text('蓝色天空'), 'getTheme': (BuildContext context) => ThemeData(useMaterial3: false, brightness: Brightness.light)}
};

String encodeQrCode(String str) {
  return ['spendbook', Moment.now().toString(), str, Moment.now().millisecond.toString()].join('#');
}

String decodeQrCode(String str) {
  return str.split('#')[2];
}

int daysBetween(DateTime a, DateTime b, [bool ignoreTime = false]) {
  if (ignoreTime) {
    int v = a.millisecondsSinceEpoch ~/ 86400000 - b.millisecondsSinceEpoch ~/ 86400000;
    if (v < 0) return -v;
    return v;
  } else {
    int v = a.millisecondsSinceEpoch - b.millisecondsSinceEpoch;
    if (v < 0) v = -v;
    return v ~/ 86400000;
  }
}

String toStringAsMoney(double amount, {dynamic fractionDigits = 2}) {
  if (amount > 10000) {
    return (fractionDigits == null ? (amount / 10000).toString() : (amount / 10000).toStringAsFixed(fractionDigits)) + '万';
  }
  return (fractionDigits == null ? amount.toString() : amount.toStringAsFixed(fractionDigits)) + '元';
}

class Choice {
  const Choice({this.title, this.icon});
  final String? title;
  final IconData? icon;
}

const List<Choice> choices = const <Choice>[
  const Choice(title: '消费', icon: IconFont.notebook),
  const Choice(title: '理财', icon: IconFont.financial),
  const Choice(title: '存款', icon: IconFont.piggybank),
];
